package com.lanjiu.lib.imclient.dto.notify;

import com.lanjiu.pro.business.BusinessProtocolEntities;
import com.lanjiu.lib.imclient.dto.base.Dto;
import com.lanjiu.lib.imclient.dto.chat.PictureDto;

/**
 * @description:
 * @author: Panwei
 * @date: 2019/11/14 17:38
 */
public class SysNotifyDto extends Dto {

    // 通知ID
    private String notifyId;

    // 通知标题
    private String title;

    // 通知内容
    private String content;

    // 通知作者
    private String author;

    // 通知时间
    private String date;

    // 通知连接
    private String url;

    // 通知图片
    private PictureDto picture;

    public SysNotifyDto() {
    }

    public String getNotifyId() {
        return notifyId;
    }

    public void setNotifyId(String notifyId) {
        this.notifyId = notifyId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public PictureDto getPicture() {
        return picture;
    }

    public void setPicture(PictureDto picture) {
        this.picture = picture;
    }

    public SysNotifyDto(BusinessProtocolEntities.SysNotify sysNotify, String path) {
        this.notifyId = sysNotify.getNotifyId();
        this.title = sysNotify.getTitle();
        this.content = sysNotify.getContent();
        this.author = sysNotify.getAuthor();
        this.date = sysNotify.getDate();
        this.url = sysNotify.getUrl();
        if (null != sysNotify.getPicture())
            this.picture = new PictureDto(sysNotify.getPicture(), path);
    }

    @Override
    public Object toProtobuf() {
        BusinessProtocolEntities.SysNotify.Builder builder = BusinessProtocolEntities.SysNotify.newBuilder();
        if (null != notifyId) builder.setNotifyId(notifyId);
        if (null != title) builder.setTitle(title);
        if (null != content) builder.setContent(content);
        if (null != author) builder.setAuthor(author);
        if (null != date) builder.setDate(date);
        if (null != url) builder.setUrl(url);
        if (null != picture)
            builder.setPicture(picture.toProtobuf());
        return builder.build();
    }
}
